package itheima.com.socketdemo7;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(5555);
        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        int b;
      while ((b=is.read())!=-1){
          System.out.println((char)b);
      }
        System.out.println("看得见我吗");
      //没有写结束标记，下面代码无法执行
       /* OutputStream os = accept.getOutputStream();
        os.write("你瞅啥".getBytes());*/

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("你瞅啥");
        bw.newLine();
        bw.flush();

        is.close();
        accept.close();
        bw.close();
        ss.close();

    }
}
